import React, {Component} from 'react'
import {Dropdown, Image, Menu, Space} from "antd";
import {useHistory} from 'umi';

export default function LoggedIn() {
    const history = useHistory()
    function logout() {
        sessionStorage.setItem("token", "")
        sessionStorage.setItem("isLogin", "0")
        history.push('/')
    }

    function retrieve() {
        history.push('/retrieve')
    }

    const menu = (
        <Menu>
            <Menu.Item key="0">
                <a target="_blank" rel="noopener noreferrer" onClick={logout}>
                    退出登录
                </a>
            </Menu.Item>
            <Menu.Item key="1">
                <a target="_blank" rel="noopener noreferrer" onClick={retrieve}>
                    修改密码
                </a>
            </Menu.Item>
        </Menu>
    );
    return (
        <Dropdown  overlay={menu}>
            <Space style={{float:"right"}}>
                <img  width={37}
                     src='https://edu-image.nosdn.127.net/49E89BEA3F1B3F1AC788F5F94C4A457F.png' alt={'user'}/>
                <Image preview={false} width={30}/>

            </Space>
        </Dropdown>

    )

};
